package com.Ajava1704.tongbu;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @类名: com.Ajava1704.tongbu
 * @作者: lgt
 * @创建时间: 2020-02-10 20:29
 * @描述:
 **/
public class Test0210tongbu {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        /*Thread t1 = new Thread(new TestR2(), "A");
        t1.start();

        Thread t2 = new Thread(new TestR2(), "B");
        t2.start();*/

        FutureTask<Integer> futureTask = new FutureTask<>(new Callable<Integer>() {
            @Override
            public Integer call() throws Exception {
                System.out.println("*****业务代码****");
                return 1;
            }
        });
        Thread thread = new Thread(futureTask);
        thread.start();

        FutureTask<Integer> futureTask1 = new FutureTask<>(new Callable<Integer>() {
            @Override
            public Integer call() throws Exception {
                System.out.println("====业务代码======");
                return 2;
            }
        });
        Thread thread1 = new Thread(futureTask1);
        thread1.start();


        Integer integer = futureTask.get();
        Integer integer1 = futureTask1.get();
//        System.out.println(integer);   1
//        System.out.println(integer1);  2
        System.out.println("==============="+(integer+integer1));   //3
    }
}
